Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
array.prototype.flatten
Advanced tools
An ESnext spec-compliant `Array.prototype.flatten` shim/polyfill/replacement that works as far down as ES3.
An ESnext spec-compliant Array.prototype.flatten
shim/polyfill/replacement that works as far down as ES3.
This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the proposed spec.
Because Array.prototype.flatten
depends on a receiver (the this
value), the main export takes the array to operate on as the first argument.
npm install --save array.prototype.flatten
var flatten = require('array.prototype.flatten');
var assert = require('assert');
var arr = [1, [2], [], 3, [[4]]];
assert.deepEqual(flatten(arr, 1), [1, 2, 3, [4]]);
var flatten = require('array.prototype.flatten');
var assert = require('assert');
/* when Array#flatten is not present */
delete Array.prototype.flatten;
var shimmedFlatten = flatten.shim();
assert.equal(shimmedFlatten, flatten.getPolyfill());
assert.deepEqual(arr.flatten(), flatten(arr));
var flatten = require('array.prototype.flatten');
var assert = require('assert');
/* when Array#flatten is present */
var shimmedIncludes = flatten.shim();
var mapper = function (x) { return [x, 1]; };
assert.equal(shimmedIncludes, Array.prototype.flatten);
assert.deepEqual(arr.flatten(mapper), flatten(arr, mapper));
Simply clone the repo, npm install
, and run npm test
FAQs
An ESnext spec-compliant `Array.prototype.flatten` shim/polyfill/replacement that works as far down as ES3.
The npm package array.prototype.flatten receives a total of 5,178 weekly downloads. As such, array.prototype.flatten popularity was classified as popular.
We found that array.prototype.flatten demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.